home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / PowerPlant / 3D Additions 1.7 / 3D Additions / 3DPanes.h < prev    next >
Encoding:
Text File  |  1995-10-24  |  5.3 KB  |  177 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. // 3DPanes.h          ©1995 J. Rodden, DD/MF & Associates. All rights reserved
  3. // ===========================================================================
  4. // Provides 3D panes (raised and inset) as proposed in Develop #15.
  5. //
  6. // There are two types of 3DPanes: panels, in which the whole pain is drawn
  7. // into, and frames, which only draw a box around the pane.
  8. //
  9. // There are also two implementations of each type of pane. The first uses the
  10. // colors stored via 3DUtilities so that all 3DPane colors can be controlled
  11. // in unison at runtime. The second is entirely resource based and gets all its 
  12. // color information from a Constructor template resource.
  13. //
  14. // This source code is loosely based on and heavily inspired by source code
  15. // by James W. Osborne, copyright (c) 1993, Apple Computer.
  16.  
  17. #pragma once
  18.  
  19. #include <LPane.h>
  20.  
  21. // ===========================================================================
  22. // Basic Panel (uses 3DUtilities set colors)
  23. // ===========================================================================
  24.  
  25. class C3DPanel : public LPane {
  26. public:
  27.     enum { class_ID = '3Dpa' };
  28.  
  29.     static void        RegisterSelf();
  30.     static C3DPanel*    CreateFromStream(LStream *inStream);
  31.  
  32.                     C3DPanel();
  33.                     C3DPanel(const SPaneInfo &inPaneInfo, const Boolean &inIsInset);
  34.                     C3DPanel(LStream *inStream);
  35.  
  36. protected:
  37.     virtual void    DrawSelf();    
  38.  
  39.     Boolean        mIsInset;
  40. };
  41.  
  42. // ===========================================================================
  43. // Basic Frame (uses 3DUtilities set colors)
  44. // ===========================================================================
  45.  
  46. class C3DFrame : public LPane {
  47. public:
  48.     enum { class_ID = '3Dfm' };
  49.  
  50.     static void        RegisterSelf();
  51.     static C3DFrame*    CreateFromStream(LStream *inStream);
  52.  
  53.                     C3DFrame();
  54.                     C3DFrame(const SPaneInfo &inPaneInfo, const Boolean &inIsInset);
  55.                     C3DFrame(LStream *inStream);
  56.  
  57. protected:
  58.     virtual void    DrawSelf();    
  59.  
  60.     Boolean        mIsInset;
  61. };
  62.  
  63.  
  64. // ===========================================================================
  65. // Resource defined 3D panel
  66. // ===========================================================================
  67.  
  68. class CThreeDPanel : public LPane {
  69. public:
  70.     enum { class_ID = '3DPA' };
  71.  
  72.     static void        RegisterSelf();
  73.     static CThreeDPanel*    CreateFromStream(LStream *inStream);
  74.  
  75.                     CThreeDPanel();
  76.                     CThreeDPanel(const SPaneInfo &inPaneInfo,
  77.                                  const RGBColor& inBkgdColor, const RGBColor& inULColor,
  78.                                  const RGBColor& inLRColor, const Boolean inHasBox);
  79.                     CThreeDPanel(LStream *inStream);
  80.                     
  81.             void    SetColors( const RGBColor& inBkgdColor, const RGBColor& inULColor,
  82.                                const RGBColor& inLRColor, const Boolean inHasBox);
  83.             void    GetColors( RGBColor& inBkgdColor, RGBColor& inULColor,
  84.                                RGBColor& inLRColor, Boolean inHasBox);
  85.  
  86. protected:
  87.     virtual void    DrawSelf();
  88.  
  89.     RGBColor    mBackgroundColor;
  90.     RGBColor    mUpperLeftColor;
  91.     RGBColor    mLowerRightColor;
  92.     Boolean        mHasBox;
  93. };
  94.  
  95. // ===========================================================================
  96. // Resource defined 3D frame
  97. // ===========================================================================
  98.  
  99. class CThreeDFrame : public LPane {
  100. public:
  101.     enum { class_ID = '3DFM' };
  102.  
  103.     static void        RegisterSelf();
  104.     static CThreeDFrame*    CreateFromStream(LStream *inStream);
  105.  
  106.                     CThreeDFrame();
  107.                     CThreeDFrame(const SPaneInfo &inPaneInfo,
  108.                                  const RGBColor& inULColor, const RGBColor& inLRColor);
  109.                     CThreeDFrame(LStream *inStream);
  110.                     
  111.             void    SetColors( const RGBColor& inULColor, const RGBColor& inLRColor);
  112.             void    GetColors( RGBColor& inULColor, RGBColor& inLRColor);
  113.  
  114. protected:
  115.     virtual void    DrawSelf();
  116.  
  117.     RGBColor    mUpperLeftColor;
  118.     RGBColor    mLowerRightColor;
  119. };
  120.  
  121.  
  122. // WARNING: The following is experimental and not currently supported.
  123. // ===========================================================================
  124. //    Once template support is available (in CW5), this templatized version may
  125. //    be better. With it you can typedef your own color styles and minimize
  126. //    data duplication. For instance:
  127. //
  128. //        typedef C3DPane<kBackgroundGray,kWhite,kShadowGray,false>    CThreeDRaisedPane;
  129. //        typedef C3DPane<kWhite,kShadowGray,kWhite,true>                CThreeDInsetPane;
  130. //        typedef C3DFrame<kWhite,kShadowGray>                        CThreeDRaisedFrame;
  131. //        typedef C3DFrame<kShadowGray,kWhite>                        CThreeDInsetFrame;
  132. //
  133. //    would give you raised and inset panes and frames respectively using the
  134. //    coloring scheme proposed in Develop #15. (For each of your own typedef'ed
  135. //    versions, be sure to use a distinct class id.)
  136. //
  137. //    NOTE: I haven't tested this version since I don't have access to a template compiler :)
  138.  
  139. //#ifdef __Templates
  140.  
  141. template <RGBColor TBKColor, RGBColor TULColor, RGBColor TLRColor, Boolean TFrameIt>
  142. class C3DPanelT : public LPane {
  143. public:
  144.     enum { class_ID = '3DPT' };
  145.  
  146.     static C3DPanelT<TBKColor,TULColor,TLRColor,TFrameIt>*
  147.                     CreateFromStream(LStream *inStream);
  148.  
  149.                     C3DPanelT();
  150.                     C3DPanelT(LStream *inStream);
  151.     
  152. protected:
  153.     virtual void    DrawSelf();    
  154.  
  155. private:
  156.  
  157. };
  158.  
  159. template <RGBColor TULColor, RGBColor TLRColor>
  160. class C3DFrameT : public LPane {
  161. public:
  162.     enum { class_ID = '3DFT' };
  163.  
  164.     static C3DFrameT<TULColor,TLRColor>*
  165.                     CreateFromStream(LStream *inStream);
  166.  
  167.                     C3DFrameT();
  168.                     C3DFrameT(LStream *inStream);
  169.     
  170. protected:
  171.     virtual void    DrawSelf();    
  172.  
  173. private:
  174.  
  175. };
  176.  
  177. //#endif    // __Templates